using UnityEngine;
using System.Collections;

public class End : MonoBehaviour 
{
	public string level;
	GameObject go;
	public GameObject fadeOut;
	
	void Start () 
	{
	
	}
	
	void Update () 
	{
		go = GameObject.Find("Main Camera");
		
		if(!go.GetComponent<Wait>().isWaiting)
		{
			Application.LoadLevel(level);
		}
	}
	
	public void OnTriggerEnter(Collider other)
	{
		if(other.gameObject.tag == "Player")
		{
			fadeOut.gameObject.SetActive(true);
			go.GetComponent<Wait>().StartWaiting(2);
		}
	}
}
